import { createApp } from 'vue'
import App from './App.vue'
import { addGlobalUncaughtErrorHandler, registerMicroApps, start } from 'qiankun';
import router from './router'

createApp(App).use(router).mount('#app')

registerMicroApps([
  {
    name: 'qiankun_child1',
    entry: 'http://172.16.10.110:8085',
    container: '#child1',
    activeRule: 'child1',
  },
  {
    name: 'qiankun_child2',
    entry: 'http://172.16.10.110:8095',
    container: '#child2',
    activeRule: 'child2',
  },
]);

addGlobalUncaughtErrorHandler((event: any) => {
  if(typeof event !== 'string') {
    const mircoAppName = event?.error?.appOrParcelName
    if(mircoAppName && event.type === 'error') {
      console.error(`${mircoAppName}应用加载失败`)
    }
  }
})

start();
